<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>{$_title}</h2>
    </div>
    <notempty name="api" >
        <form action="{:U('Api/editApi')}" method="post" class="form-horizontal">
            <else />
            <form action="{:U('Api/addApi')}" method="post" class="form-horizontal">
                </notempty>
                <notempty name="api">
                    <input type="hidden" name="id" value="{$api.id}" />
                </notempty>
                <div class="form-item">
                    <label class="item-label">API Code<span class="check-tips">（API Code会作为API的唯一标识，只能包括字母、数字和下划下，至少2个字符且以下划下开头，修改此项请三思！！！）</span></label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="api_code" value="{$api.api_code}">
                    </div>
                </div>
                <div class="form-item">
                    <label class="item-label">API Name<span class="check-tips">（API名称，可以包括中文，至少2个字符）</span></label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="api_name" value="{$api.api_name|default=''}">
                    </div>
                </div>
                <div class="form-item">
                    <label class="item-label">API Module<span class="check-tips">（API模块，只能包括字母、数字和下划下，至少2个字符，默认为Home模块）</span></label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="api_module" value="{$api.api_module|default='Home'}">
                    </div>
                </div>
                <div class="form-item">
                    <label class="item-label">API Controller<span class="check-tips">（API控制器，只能包括字母、数字和下划下，至2个字符）</span></label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="api_controller" value="{$api.api_controller|default=''}">
                    </div>
                </div>
                <div class="form-item">
                    <label class="item-label">API Action<span class="check-tips">（API操作，只能包括字母、数字和下划下，至少2个字符）</span></label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="api_action" value="{$api.api_action|default=''}">
                    </div>
                </div>
                <div class="form-item">
                    <label class="item-label">API Method<span class="check-tips">（API请求方式）</span></label>
                    <div class="controls">
                        <select name="api_method" class="input-large">
                            <foreach name="Think.config.API_REQUEST" key="key" item="val">
                                <if condition="$key eq $api['api_method']">
                                    <option value="{$key}" selected>{$val}</option>
                                    <else />            			
                                    <option value="{$key}">{$val}</option>
                                </if>
                            </foreach>
                        </select>
                    </div>
                </div>
                <div class="form-item">
                    <label class="item-label">API Param<span class="check-tips">（API请求参数，接口使用者查阅）</span></label>
                    <div class="controls">
                        <textarea rows="5" class="input-large kind-editor" name="api_param">{$api.api_param|default=''}</textarea>
                    </div>
                </div>
                <div class="form-item">
                    <label class="item-label">API Description<span class="check-tips">（API描述）</span></label>
                    <div class="controls">
                        <textarea rows="5" class="input-large kind-editor" name="api_desc">{$api.api_desc|default=''}</textarea>
                    </div>
                </div>
                <div class="form-item">
                    <label class="item-label">API Example<span class="check-tips">（API请求示例）</span></label>
                    <div class="controls">
                        <textarea rows="5" class="input-large kind-editor" name="api_example">{$api.api_example|default=''}</textarea>
                    </div>
                </div>
                <div class="form-item">
                    <label class="item-label">API Param Json<span class="check-tips">（API请求参数，接口开发者使用）</span></label>
                    <div class="controls">
                        <textarea style="width:890px;height:280px;padding:5px;" class="input-large" name="api_param1">{$api.api_param1|default=''}</textarea>
                    </div>
                </div>
                <div class="form-item">
                    <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
                    <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
                </div>
            </form>
            </block>

            <block name="script">
                <link rel="stylesheet" href="__PUBLIC__/static/kindeditor/default/default.css" />
                <script charset="utf-8" src="__PUBLIC__/static/kindeditor/kindeditor-min.js"></script>
                <script charset="utf-8" src="__PUBLIC__/static/kindeditor/zh_CN.js"></script>
                <script type="text/javascript">
                        KindEditor.ready(function (K) {
                            window.editor = K.create('textarea[class="kind-editor"]', {
                                //allowFileManager : false
                                minWidth: 900,
                                minHeight: 300,
                                afterBlur: function () {
                                    this.sync();
                                },
                            });
                        });

                        //导航高亮
                        highlight_subnav("{:U('Api/apiList')}");
                </script>
            </block>
